package com.ss.android.article.browser.download.b;

import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

import com.ss.android.common.app.AbsApplication;

import java.io.File;
import java.text.DecimalFormat;

public final class a {
    private static final ThreadLocal<DecimalFormat> a;

    static {
        a = new b();
    }

    public static String a(long arg6) {
        String v0;
        long v4 = 1073741824;
        long v2 = 1048576;
        if (arg6 < 1024) {
            v0 = (((int) arg6)) + "B";
        } else if (arg6 < v2) {
            v0 = (((int) arg6)) / 1024 + "KB";
        } else if (arg6 < v4) {
            v0 = a.get().format(arg6 / v2) + "MB";
        } else {
            v0 = a.get().format(arg6 / v4) + "GB";
        }

        return v0;
    }

    public static boolean a(String arg6) {
        boolean v0 = false;
        int v2 = (TextUtils.isEmpty(arg6)) || !arg6.startsWith(File.separator) ? 0 : 1;
        if (v2 != 0) {
            File v2_1 = new File(arg6);
            if ((v2_1.exists()) && (v2_1.isFile()) && v2_1.length() > 0) {
                v0 = true;
            }
        }

        return v0;
    }

    public static boolean b(String arg1) {
        boolean v0 = arg1 == null || !arg1.endsWith(".apk") ? false : true;
        return v0;
    }

    public static void c(String arg3) {
        try {
            Intent v0_1 = new Intent("android.intent.action.VIEW");
            v0_1.setDataAndType(Uri.fromFile(new File(arg3)), "application/vnd.android.package-archive");
            AbsApplication.getApplication().startActivity(v0_1);
        } catch (Exception v0) {
        }
    }
}

